<template>
  <div>
    <myHeader></myHeader>
    <h2 v-text="data.title"></h2>
    <p>作者：{{ data.author.loginname }} 发表于：{{ $utils.goodTime(data.create_at) }}</p>
    <hr>
    <article v-html="data.content"></article>
    <hr>
    <ul>
      <li v-for="i in data.replies" :key="i.id">
        <p>评论者： {{ i.author.loinname }} 评论于： {{ $utils.goodTime(data.create_at) }}</p>
        <article v-html="i.content"></article>
      </li>
    </ul>
  </div>
</template>

<script>
import myHeader from '../components/header.vue'
import myFooter from '../components/footer.vue'
export default {
  components: {
    myHeader,
    myFooter
  },
  data () {
    return {
      id: this.$route.params.id,
      data: {}
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      this.$api.get('topic/' + this.id, null, r => {
        this.data = r.data
      })
    }
  }
}
</script>
